# Contributor: Dennis Krupenik <dennis@krupenik.com>
# Maintainer: Dennis Krupenik <dennis@krupenik.com>
pkgname=one-dnn
pkgver=3.1
pkgrel=0
pkgdesc="oneAPI Deep Neural Network Library"
url="https://01.org/oneDNN"
# Used to executed primitives on Intel 64bit, aarch64 and compatible devices
arch="x86_64"
license="Apache-2.0"
depends_dev="onetbb-dev opencl-headers opencl-icd-loader-dev"
makedepends="cmake samurai $depends_dev"
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/oneapi-src/oneDNN/archive/v$pkgver/oneDNN-$pkgver.tar.gz
	gcc13.patch
	"
builddir="$srcdir/oneDNN-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	# if not release type, debug is selected
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DDNNL_GPU_RUNTIME=OCL \
		-DDNNL_CPU_RUNTIME=TBB \
		-DONEDNN_BUILD_GRAPH=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest -E '(gpu|cross-engine|api)' --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
2053157a3885618364a9da5ec738c9cc2dde15db1ce9737578565d25c4a15a65944db3bbd17780de2032cfa2329bea4cb0af24ee428c9c246bdfa07a5bdde30b  oneDNN-3.1.tar.gz
356b2d6e2aa3156e92e23872ee6643ba0d27de08af15fdd9dcf0f6dd45eaf30bf8506dbcc3594981f5a8a68fadf9d790b4b2c920c33675bc316aea6fb5a26d6b  gcc13.patch
"
